package org.gitman.agent.algorithms;

import org.gitman.agent.platform.Agent;
import org.gitman.agent.platform.AgentManager;
import org.gitman.agent.platform.AgentUtils;

import com.mxgraph.model.mxICell;
import com.mxgraph.view.mxGraph;

public class NonStopAgent extends Agent{

	public NonStopAgent() {
		name = "NonStopAgent";
		description = "Choosing shortest path (based on BFS), stops only if can't move";
	}
	
	@Override
	public Agent getInstance() {
		return new NonStopAgent();
	}

	@Override
	public mxICell doStep(mxGraph graph, AgentManager agentManager) {
		mxICell [] path = AgentUtils.getShortestPath(graph, currentPoint, endPoint);
		if(path.length > 0 && !AgentUtils.isCellOcupied(path[1], graph)){
			return path[1];
		}
		return currentPoint;
	}

}
